package entities;

import java.util.ArrayList;

/**
 * Entity Class for OtherEvent. OtherEvent is a Event with a description.
 * 
 * @author MK
 * @see entities.Event
 * 
 */
public class OtherEvents extends Event {

	private String description;

	private OtherEvents() {
		super();
	}

	public OtherEvents(Long date, Address place,
			ArrayList<Participant> participants, String description) {
		super(date, place, participants);
		this.description = description;
	}

	public OtherEvents(OtherEvents otherEvent) {
		this(otherEvent.date, otherEvent.place, otherEvent.participants,
				otherEvent.description);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		OtherEvents other = (OtherEvents) obj;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "OtherEvent [description=" + description + ", date=" + date
				+ ", participants=" + participants + ", place=" + place + "]";
	}

	public int compareTo(OtherEvents otherEvent) {

		if (super.compareTo((Event) otherEvent) != 0) {
			return super.compareTo((Event) otherEvent);
		} else {
			return this.description.compareTo(otherEvent.description);
		}
	}

	public String getDescription() {
		return description;
	}
}
